const express = require('express');
const router = express.Router();
const authenticateToken = require('../middleware/authMiddleware'); // 引入身份验证中间件

const { getAllItems, getItemByUserId, getItemById, addItem, updateItem, deleteItem } = require('../controllers/itemController');

router.get('/', getAllItems);
// 将 /user 路由放在 /:id 路由之前
router.get('/user', authenticateToken, getItemByUserId); 
router.get('/:id', getItemById);
router.post('/', authenticateToken, addItem);
router.put('/:id', authenticateToken, updateItem);
router.delete('/:id', authenticateToken, deleteItem);

module.exports = router;